home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #1 / Ham Radio 2000.iso / ham2000 / tcp_ip / tnos / tnos100s / iface.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-02-14  |  5.5 KB  |  147 lines

  1. #ifndef    _IFACE_H
  2. #define    _IFACE_H
  3.  
  4. #ifndef    _GLOBAL_H
  5. #include "global.h"
  6. #endif
  7.  
  8. #ifndef    _MBUF_H
  9. #include "mbuf.h"
  10. #endif
  11.  
  12. #ifndef _PROC_H
  13. #include "proc.h"
  14. #endif
  15.  
  16. /* Interface encapsulation mode table entry. An array of these structures
  17.  * are initialized in config.c with all of the information necessary
  18.  * to attach a device.
  19.  */
  20. struct iftype {
  21.     char *name;        /* Name of encapsulation technique */
  22.     int (*send) __ARGS((struct mbuf *,struct iface *,int32,int,int,int,int));
  23.                 /* Routine to send an IP datagram */
  24.     int (*output) __ARGS((struct iface *,char *,char *,int16,struct mbuf *));
  25.                 /* Routine to send link packet */
  26.     char *(*format) __ARGS((char *,char *));
  27.                 /* Function that formats addresses */
  28.     int (*scan) __ARGS((char *,char *));
  29.                 /* Reverse of format */
  30.     int type;        /* Type field for network process */
  31.     int hwalen;        /* Length of hardware address, if any */
  32. };
  33. #define    NULLIFT    (struct iftype *)0
  34. extern struct iftype Iftypes[];
  35.  
  36.  
  37. /* Interface control structure */
  38. struct iface {
  39.     struct iface *next;    /* Linked list pointer */
  40.     char *name;        /* Ascii string with interface name */
  41.     char *descr;    /* Description of interface */
  42.  
  43.     int32 addr;        /* IP address */
  44.     int32 broadcast;    /* Broadcast address */
  45.     int32 netmask;        /* Network mask */
  46.  
  47.     int16 mtu;        /* Maximum transmission unit size */
  48.     int16 paclen;   /* AX.25 paclen, if applicable */
  49.  
  50.     int16 flags;        /* Configuration flags */
  51. #define DATAGRAM_MODE   0   /* Send datagrams in raw link frames */
  52. #define    CONNECT_MODE    1    /* Send datagrams in connected mode */
  53. #define IS_NR_IFACE     2   /* Activated for NET/ROM - WG7J */
  54. #define NR_VERBOSE      4   /* NET/ROM broadcast is verbose - WG7J */
  55. #define IS_CONV_IFACE   8   /* Activated for conference call access - WG7J */
  56. #define AX25_BEACON     16  /* Broadcast AX.25 beacons */
  57. #define MAIL_BEACON     32  /* Send MAIL beacons */
  58. #define HIDE_PORT       64  /* Don't show port in mbox P command */
  59. #define AX25_DIGI       128 /* Allow digipeating */
  60. #define ARP_EAVESDROP   256 /* Listen to ARP replies */
  61. #define ARP_KEEPALIVE   512 /* Keep arp entries alive after timeout */
  62. #define LOG_AXHEARD    1024 /* Do ax.25 heard logging on this interface */
  63. #define LOG_IPHEARD    2048 /* Do IP heard logging on this interface */
  64.  
  65.     int quality;            /* Netrom interface quality */
  66.  
  67.     int16 trace;        /* Trace flags */
  68. #define    IF_TRACE_OUT    0x01    /* Output packets */
  69. #define    IF_TRACE_IN    0x10    /* Packets to me except broadcast */
  70. #define    IF_TRACE_ASCII    0x100    /* Dump packets in ascii */
  71. #define    IF_TRACE_HEX    0x200    /* Dump packets in hex/ascii */
  72. #define    IF_TRACE_NOBC    0x1000    /* Suppress broadcasts */
  73. #define    IF_TRACE_RAW    0x2000    /* Raw dump, if supported */
  74.     char *trfile;        /* Trace file name, if any */
  75.     FILE *trfp;        /* Stream to trace to */
  76.  
  77.     struct iface *forw;    /* Forwarding interface for output, if rx only */
  78.  
  79.     struct proc *rxproc;    /* Receiver process, if any */
  80.     struct proc *txproc;    /* Transmitter process, if any */
  81.     struct proc *supv;    /* Supervisory process, if any */
  82.  
  83.     /* Device dependant */
  84.     int dev;        /* Subdevice number to pass to send */
  85.                 /* To device -- control */
  86.     int32 (*ioctl) __ARGS((struct iface *,int cmd,int set,int32 val));
  87.                 /* From device -- when status changes */
  88.     int (*iostatus) __ARGS((struct iface *,int cmd,int32 val));
  89.                 /* Call before detaching */
  90.     int (*stop) __ARGS((struct iface *));
  91.     char *hwaddr;        /* Device hardware address, if any */
  92.     char *ipcall;        /* Device IP call sign, if any */
  93.  
  94.     /* Encapsulation dependant */
  95.     void *edv;        /* Pointer to protocol extension block, if any */
  96.     int type;        /* Link header type for phdr */
  97.     int xdev;        /* Associated Slip or Nrs channel, if any */
  98.     int port;        /* Sub port for multy port kiss */
  99.     struct iftype *iftype;    /* Pointer to appropriate iftype entry */
  100.  
  101.             /* Encapsulate an IP datagram */
  102.     int (*send) __ARGS((struct mbuf *,struct iface *,int32,int,int,int,int));
  103.             /* Encapsulate any link packet */
  104.     int (*output) __ARGS((struct iface *,char *,char *,int16,struct mbuf *));
  105.             /* Send raw packet */
  106.     int (*raw)        __ARGS((struct iface *,struct mbuf *));
  107.             /* Display status */
  108.     void (*show)        __ARGS((struct iface *));
  109.  
  110.     int (*discard)        __ARGS((struct iface *,struct mbuf *));
  111.     int (*echo)        __ARGS((struct iface *,struct mbuf *));
  112.  
  113.     /* Counters */
  114.     int32 ipsndcnt;     /* IP datagrams sent */
  115.     int32 rawsndcnt;    /* Raw packets sent */
  116.     int32 iprecvcnt;    /* IP datagrams received */
  117.     int32 rawrecvcnt;    /* Raw packets received */
  118.     int32 lastsent;        /* Clock time of last send */
  119.     int32 lastrecv;        /* Clock time of last receive */
  120. };
  121. #define    NULLIF    (struct iface *)0
  122. extern struct iface *Ifaces;    /* Head of interface list */
  123. extern struct iface  Loopback;    /* Optional loopback interface */
  124. extern struct iface  Encap;    /* IP-in-IP pseudo interface */
  125.  
  126. /* Header put on front of each packet in input queue */
  127. struct phdr {
  128.     struct iface *iface;
  129.     unsigned short type;    /* Use pktdrvr "class" values */
  130. };
  131. extern char Noipaddr[];
  132. extern struct mbuf *Hopper;
  133.  
  134. /* In iface.c: */
  135. struct iface *if_lookup __ARGS((char *name));
  136. struct iface *ismyaddr __ARGS((int32 addr));
  137. int if_detach __ARGS((struct iface *ifp));
  138. int setencap __ARGS((struct iface *ifp,char *mode));
  139. char *if_name __ARGS((struct iface *ifp,char *comment));
  140. int bitbucket __ARGS((struct iface *ifp,struct mbuf *bp));
  141. int dosetflag __ARGS((int argc,char *argv[],void *p,int flagtoset, int AX25only));
  142.  
  143. /* In config.c: */
  144. int net_route __ARGS((struct iface *ifp,int type,struct mbuf *bp));
  145.  
  146. #endif    /* _IFACE_H */
  147.